$(document).ready(function(){
	$("#pageFormContent2").hide();
	$("#channelBtn_gen").click(function(){
		asyncbox.open({
			url : "../channel_findEChannelGeneratePrice.action",
			width : 650,
			height : 450,
			top : 65,
			drag : false,
			modal : true,
			scrolling : "yes",
			title : "渠道信息",
			tipsbar : {
				title : '渠道信息查询',
				content : '渠道信息查询'
			},
			btnsbar : $.btn.OKCANCEL,
			callback : function(action,iframe,returnValue){
				if(action == 'ok'){
					var strs = returnValue.split("|:,:|");
					$("#channel_gen").attr("value",strs[1]);
					$("#channelNum_gen").attr("value",strs[0]);
					var stp = document.getElementById("sfenqu_gen");
					stp.options.length = 1;
					$.post("../partitionJson!findSPartitions.action",{"channelNumber":strs[0]},function(data){
						$(data.spartitions).each(function(){
							stp.options.add(new Option(this.partition_name,this.partition_number));
						});
					});
				}else{
					
				}
			}
		});
	});
	var chType = "";
	$("#channelTypeBtn_gen").click(function(){
		asyncbox.open({
			url : "../generatePrice_searchChannelTypes.action",
			width : 650,
			height : 450,
			top : 65,
			drag : false,
			modal : true,
			scrolling : "yes",
			title : "渠道类别信息",
			tipsbar : {
				title : '渠道类别信息查询',
				content : '渠道类别信息查询'
			},
			btnsbar : $.btn.OKCANCEL,
			callback : function(action,iframe,returnValue){
				if(action == 'ok'){
					var strs = returnValue.split("||");
					$("#channelType_gen").attr("value",strs[1]);
					$("#channelTypeNum_gen").attr("value",strs[0]);
					if(chType != strs[1]){
						$("#schannel_gen").attr("value","");
						$("#schannelNum_gen").attr("value","");
					}
					chType = strs[1];
				}else{
					
				}
			}
		});
	});
	$("#schannelBtn_gen").click(function(){
		var types = $("#channelTypeNum_gen").val();
		var fuel = $("input[name='price.PPriceFuel']:checked").val();
		asyncbox.open({
			url : "../generatePrice_searchSourceChannels.action?types="+types+"&fuel="+fuel,
			width : 650,
			height : 450,
			top : 65,
			drag : false,
			modal : true,
			scrolling : "yes",
			title : "渠道信息",
			tipsbar : {
				title : '渠道信息查询',
				content : '渠道信息查询'
			},
			btnsbar : $.btn.OKCANCEL,
			callback : function(action,iframe,returnValue){
				if(action == 'ok'){
					var strs = returnValue.split("||");
					$("#schannel_gen").attr("value",strs[1]);
					$("#schannelNum_gen").attr("value",strs[0]);
				}else{
					
				}
			}
		});
	});
	
	$("input[name='price.PPriceFuel']").change(function(){
		$("#schannel_gen").attr("value","");
		$("#schannelNum_gen").attr("value","");
	});
	
	
	
	//下一步按钮
	$("#theNextBtn_gen").click(function(){
		if($("#channelNum_gen").val() == ""){
			alertMsg.error("请选择目的报价渠道");
			return;
		}
		if($("#sfenqu_gen").val() == ""){
			alertMsg.error("请选择起始分区");
			return;
		}
		if($("#clientClass_gen").val() == ""){
			alertMsg.error("请选择客户类别");
			return;
		}
		if($("#sourceChannelNumbers").val() == ""){
			alertMsg.error("请选择源渠道");
			return;
		}
		if($("#priceStartDate_gen").val() == ""){
			alertMsg.error("请选择生效日期");
			return;
		}
		if($("#priceEndDate_gen").val() == ""){
			alertMsg.error("请选择结束日期");
			return;
		}
		if($("#priceEndDate_gen").val()<=$("#sourceChannelNumbers").val()){
			alertMsg.error("请正确的选择结束日期");
			return;
		}
		$.post("../generatePrice_findECountrys.action",{"channelNum":$("#channelNum_gen").val(),"isBig":$(":radio[name='isBig']:checked").val(),"sourceChannelNumbers":$("#schannelNum_gen").val()},function(data){
			$("#note_gen").html("目的报价渠道:<font color='red'>"+ $("#channel_gen").val() +"</font>;&nbsp起始分区:"
				+"<font color='red'>"+ $("#sfenqu_gen option:selected").html() +"</font>;&nbsp客户类型:<font color='red'>"+$("#clientClass_gen option:selected").get(0).innerText+"</font>" +
				";&nbsp;所选源渠道:<font color='red'>"+$("#schannel_gen").val()+"</font>");
			$("#priceTab1_gen").html(data);
		});
		$("#pageFormContent1_gen").fadeOut("normal");
		$("#pageFormContent2_gen").show("slow");
	});
	//上一步按钮
	$("#theBackBtn_gen").click(function(){
		$("#priceTab1_gen").html();
		$("#pageFormContent2_gen").fadeOut("normal");
		$("#pageFormContent1_gen").show("slow");
	});
	
});